<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.edu.lingnan.pojo.Project" %>
<%@ page import="cn.edu.lingnan.pojo.User" %>

<html><%
    User user = (User) session.getAttribute("user");
    List<Project> noprojects = (List<Project>) session.getAttribute("noprojects");
%>
<head>
    <title>项目查询</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <script>
        function showAlert(message) {
            alert(message);
        }
    </script>
</head>
<body>
<div class="container">
    <h1 class="mt-5">项目查询</h1>
    <div class="table-responsive">
        <table class="table table-bordered table-striped mt-3">
            <thead class="thead-dark">
            <tr>
                <th>项目ID</th>
                <th>项目名称</th>
                <th>导师ID</th>
                <th>导师姓名</th>
                <th>类型</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th>状态</th>
                <th>描述</th>
                <th>成员</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <%
                if (noprojects != null) {
                    for (Project project : noprojects) {
            %>
            <tr>
                <td><%= project.getProtectId() %></td>
                <td><%= project.getProjectName() %></td>
                <td><%= project.getPostId() %></td>
                <td><%= project.getPostName() %></td>
                <td><%= project.getType() %></td>
                <td><%= project.getStartTime() %></td>
                <td><%= project.getEndTime() %></td>
                <td>1</td>
                <td><%= project.getDescription() %></td>
                <td><%= project.getMembers() %></td>
                <td>
                    <form action="enterproject" method="post" onsubmit="showAlert('已发送申请')">
                        <input type="hidden" name="name" value="<%= user.getName() %>">
                        <input type="hidden" name="userId" value="<%= user.getId() %>">
                        <input type="hidden" name="protectId" value="<%= project.getProtectId() %>">
                        <input type="hidden" name="action" value="apply">
                        <input type="submit" class="btn btn-primary" value="申请加入">
                    </form>
                </td>
            </tr>
            <%
                }
            } else {
            %>
            <tr>
                <td colspan="11" class="text-center">没有项目信息</td>
            </tr>
            <%
                }
            %>
            </tbody>
        </table>
    </div>
</div>
</body>
</html>
